// import axios from 'axios'
// axios.defaults.baseURL = process.env.VUE_APP_URL

import request from '../utils/request.js'

// 登录接口调用
export function authorizationsPost (data) {
  return request({
    url: '/v1_0/authorizations',
    method: 'post',
    data: data
  })
}

// 用户信息接口
export function profile () {
  return request({
    url: '/v1_0/user/profile',
    method: 'get'
    // headers: {
    //   Authorization: `Bearer ${getItem()}`
    // }
  })
}

// 频道数据接口
export function channels () {
  return request({
    url: '/v1_0/channels',
    method: 'get'
  })
}

// 获取文章列表接口
export function articles (params) {
  return request({
    url: '/v1_0/mp/articles',
    params
    // headers多次使用 可以设置在请求拦截中
    // headers: {
    //   Authorization: `Bearer ${getItem()}`
    // }
  })
}

// 发表文章
export function articlesPost (data, draft) {
  return request({
    url: '/v1_0/mp/articles',
    method: 'post',
    data,
    params: { draft: draft }
  })
}

// 删除文章
export function articlesDel (id) {
  return request({
    url: '/v1_0/mp/articles/' + id,
    method: 'delete'
  })
}

// 文章详情
export function articlesGet (id) {
  return request({
    url: '/v1_0/mp/articles/' + id,
    method: 'get'
  })
}

// 编辑文章
export function articlesPut (data, draft) {
  return request({
    url: '/v1_0/mp/articles/' + data.id,
    method: 'put',
    data,
    params: {
      draft: draft
    }
  })
}
